package com.example.mobile2021606144ywr0421homework;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class rcy extends RecyclerView.Adapter<rcy.holder> {
    List<car> list;
    public rcy(List<car>list){this.list=list;}
    @NonNull
    @Override
    public rcy.holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.tv_main_result,null);
        holder holder=new holder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull holder holder, int position) {
        car car=list.get(position);
        holder.tv_title1.setText(car.getHuanjie());
        holder.tv_title2.setText(car.getWeizhi());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class holder extends RecyclerView.ViewHolder {
        private TextView tv_title1;
        private TextView tv_title2;
        public holder(@NonNull View itemView) {
            super(itemView);
            this.tv_title1=itemView.findViewById(R.id.tv_title1);
            this.tv_title2=itemView.findViewById(R.id.tv_title2);
        }
    }
}
